package com.ruoyi.web.controller.tool;

import com.ruoyi.common.utils.StringUtils;

import java.util.Random;

public class ShortLinkGenerator {
    private static final String BASE62 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    private static final int SHORT_LINK_LENGTH = 5; // 短链长度

    public static String generateShortLink() {
        StringBuilder shortLink = new StringBuilder(SHORT_LINK_LENGTH);
        Random random = new Random();
        for (int i = 0; i < SHORT_LINK_LENGTH; i++) {
            int index = random.nextInt(BASE62.length());
            shortLink.append(BASE62.charAt(index));
        }
        return shortLink.toString();
    }
}
